'''
Created on Apr 29, 2012
TC ID: Ecom_5032
Desc: Kiem thu chuc nang xoa Module
@author: lavang
'''
import unittest
from Functions.globalFunc import preCondition, readData, endCondition
from Functions.loginPageFunc import login
from HTMLTestRunner import HTMLTestRunner
import time
from Functions.moduleFunc import clickOnModule,\
     deleteModule, isModuleDelete

username=readData("username")
password=readData("password")
fileName="module_empty"

class Ecom_5032(unittest.TestCase):


    def setUp(self):
        preCondition(self)

    def test_Ecom_5032(self):
        print "Buoc 1: Dang nhap website"
        login(self,username,password)
        
        print "Buoc 2: Vao trang cai dat Module"
        clickOnModule(self)
        
        print "Buoc 3: Xoa Module"
        deleteModule(self,fileName)
        
        print "Buoc 4: Xac nhan xoa Module thanh cong"
        self.assertFalse(isModuleDelete(self,fileName), "Failed!")
        print "Passed! Module duoc xoa thanh cong"
    
    def tearDown(self):
        endCondition(self)



if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    testSuite = unittest.TestSuite()
    suite = unittest.TestLoader().loadTestsFromTestCase(Ecom_5032)
    dateTime = time.strftime('%Y%m%d_%H_%M_%S')
    buf = file("../../Report/TestResults" + "_" + dateTime + ".html",'wb')
    runner = HTMLTestRunner(
                    stream=buf,
                    title='Test Results',
                    description='Kiem thu chuc nang xoa mot Module'
                    )
    runner.run(suite)